<?php

class Outils_Form {

  public static function makeCombo($name,$tableau,$selectedValue) {
    $html="";
    $html.="<select name=\"{$name}\" id=\"{$name}\">\n";
    foreach($tableau as $cle=>$value){
      if($cle==$selectedValue){
     $html.="<option value=\"{$cle}\" selected=\"selected\">{$value}</option>";
      }
      else{
     $html.="<option value=\"{$cle}\">{$value}</option>";
      }
    }


    $html.= "</select>";

 return $html;
  }

     static public function makeCheckbox($name, $tableau, $selectedValues){


    $html="";

    if(sizeof($selectedValues)>0) {
      $tabChecked = $selectedValues; }
    else {
      $tabChecked=array(); }
    $html.="<ul>";

    foreach($tableau as $cle => $value){
	if ($tabChecked=="") {$tabChecked=array();} // sinon erreur d'argument
      $check=in_array($cle, $tabChecked) ? "checked=\"checked\"" : "";
      $html .= <<<EOT
	<li><input type="checkbox" value="{$cle}" name="{$name}[]" {$check} />{$value}</li>
EOT;
      
    }
    $html.="</ul>";
	 

    return $html;

  }


}

?>
